package com.longlonggo.config;

import com.longlonggo.interceptor.BaseInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 注册自定义拦截器，即baseInterceptor，用于实现在拦截器中统一添加路径参数
 *
 * @author 石马人山 me@longlonggo.com
 * @version 100-000-000<br/>
 * @Created 2018年5月3日 下午4:02:16
 * </p>
 * @description <br/>
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private BaseInterceptor baseInterceptor;
//    @Autowired
//    private ErrorInterceptor errorInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(baseInterceptor).addPathPatterns("/**");
//        registry.addInterceptor(errorInterceptor).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}
